package Thread;

import java.util.Random;

public class demo6 {
    public static void main(String[] args) {
        int[] arr = new int[10000000];
        Random random = new Random();
        for (int i = 0; i < arr.length; i++) {
            int ran = random.nextInt(100) + 1;
            arr[i] = ran;
        }
        Thread t1 = new Thread(() -> {
            int sum = 0;
            for(int i = 0;i < arr.length;i += 2) {
                sum += arr[i];
            }
            System.out.println(sum);
        });
        Thread t2 = new Thread(() -> {
           int sum = 0;
            for (int i = 1; i < arr.length; i += 2) {
                sum += arr[i];
            }
            System.out.println(sum);
        });
        t1.start();
        t2.start();
    }
}
